package com.wxg.json.bean;

import java.util.ArrayList;
import java.util.List;

public class CommandBean {

	private String name;
	private String command;
	private String dir;
	private String port = "0000";
	private boolean isAlive = false;
	private long id = System.nanoTime();
	
	public CommandBean(){}
	
	public CommandBean(String name, String command){
		this(name, command, System.getProperty("user.dir"));
	}
	
	public CommandBean(String name, String command, String dir){
		this(name, command, dir, "0000");
	}
	
	public CommandBean(String name, String command, String dir, String port){
		this.name = name;
		this.command = command;
		this.dir = dir.contains("\\") ? dir.replaceAll("\\", "/") : dir;
		this.port = port;
	}
	
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public String getCommand() {
		return command;
	}
	public void setCommand(String command) {
		this.command = command;
	}
	public String getPort() {
		return port;
	}
	public void setPort(String port) {
		this.port = port;
	}
	public String getDir() {
		return dir;
	}
	public void setDir(String dir) {
		this.dir = dir;
	}
	public boolean isAlive() {
		return isAlive;
	}
	public void setAlive(boolean isAlive) {
		this.isAlive = isAlive;
	}
	public long getId() {
		return id;
	}

	@Override
	public String toString() {
		return "CommandBean [name=" + name + ", command=" + command + ", dir=" + dir + ", port=" + port + ", isAlive="
				+ isAlive + ", id=" + id + "]";
	}

	public List<Object> list(){
		List<Object> list = new ArrayList<Object>();
		list.add(name);
		list.add(command);
		list.add(dir);
		list.add(port);
		list.add(isAlive);
		return list;
	}
	
	public Object[] arr(){
		return list().toArray(new Object[]{});
	}
}
